﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Jemgine.MapEditor
{
    public partial class MapRenderControl
    {
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == ( Keys.Delete ))
            {
                EditorState.PerformOperation(new Operations.Delete(EditorState.Selected, EditorState.MultiSelection));
                return true;
            }
            else if (keyData == ( Keys.Up ) )
            {
                EditorState.PerformOperation(new Operations.ChangeElementOrder(EditorState.Selected,
                    Operations.ChangeElementOrder.Direction.Up));
                return true;
            }
            else if (keyData == ( Keys.Down ) )
            {
                EditorState.PerformOperation(new Operations.ChangeElementOrder(EditorState.Selected,
                    Operations.ChangeElementOrder.Direction.Down));
                return true;
            }
            else if (keyData == (Keys.PageDown))
            {
                EditorState.PerformOperation(new Operations.ChangeElementOrder(EditorState.Selected,
                    Operations.ChangeElementOrder.Direction.Front));
                return true;
            }
            else if (keyData == Keys.Space)
            {
                if (EditorState.Selected.Type == Jemgine.Engine.Selection.Types.None) return true;
                if (EditorState.MultiSelection.Contains(EditorState.Selected))
                    EditorState.MultiSelection.Remove(EditorState.Selected);
                else
                    EditorState.MultiSelection.Add(EditorState.Selected);
                return true;
            }
            else if (keyData == Keys.Escape)
            {
                EditorState.MultiSelection.Clear();
                return true;
            }

            return base.ProcessCmdKey(ref msg, keyData);
        }
    }
}
